import torch

criterion = torch.nn.CrossEntropyLoss()
Y = torch.LongTensor([2, 0, 1])
Y_pred_1 = torch.Tensor([[0.1, 0.2, 0.9],
                         [1.1, 0.1, 0.2],
                         [0.2, 2.1, 0.1]])
Y_pred_2 = torch.Tensor([[0.8, 0.2, 0.3],
                         [1.2, 0.3, 0.5],
                         [0.2, 0.2, 0.5]])
# loss_01 = criterion(Y_pred_1, Y)
loss_01 = criterion(Y_pred_1, Y)
# loss_02 = criterion(Y_pred_2, Y)
loss_02 = criterion(Y_pred_2, Y)

print('Batch Loss1 = ', loss_01.data, '\nBatch Loss2 = ', loss_02.data)
